﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using LinQProject;
using LinQProject.Repository;

namespace ServiceProject.EntityService
{
    public class ConversationDetailsService:DataBaseProcessBase<ConversationDetail>
    {
        public ConversationDetailsService(FarmacieDataClassesDataContext database) : base(database)
        {
        }

        public bool InsertUpdate(ConversationDetail conversationDetailItem, out int id, out Exception eroare)
        {
            eroare = null;
            id = 0;
            if (conversationDetailItem.ConversationDetailsId == 0)
            {
               try
               {
                   id = (int)base.Add(conversationDetailItem, "ConversationDetailsId");
               }
                catch(Exception exc)
                {
                    eroare = exc;
                    return false;
                }
            }
            else
            {
                try
                {
                    base.Update(conversationDetailItem, c => c.ConversationId == conversationDetailItem.ConversationDetailsId);
                }
                catch(Exception exc)
                {
                    eroare = exc;
                    return false;
                }
            }
            return true;
        }
    }
}
